package com.cx.purchase.legalplant.mapper;

import com.cx.purchase.legalplant.model.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface LegalPlantMapper {
    //所有的数据
    List<LegalPlantVO> queryData(LegalPlantSelectVo legalPlantSelectVo);
    //总条数
    int queryCount(LegalPlantSelectVo legalPlantSelectVo);

    @Insert("insert into factory(legalPlantCode,legalPlantDec,enabled,legalPersonCode,createName,createTime,updateName,updateTime)\n" +
            "\t\t values (#{legalPlantCode},#{legalPlantDec},#{enabled},#{legalPersonCode},\n" +
            "\t\t #{createName},#{createTime},#{updateName},#{updateTime})")
    void add(LegalPlantVO legalPlantVO);
    @Select("select * from factory where legalPlantCode = #{legalPlantCode}")
    LegalPlantVO queryByCode(String legalPlantCode);

    @Select("select * from legalperson where legalPersonCode = #{legalPersonCode}")
    LegalPersonVO queryByPersonCode(String legalPersonCode);

    @Select("select * from legalperson where userId = #{id}")
    List<LegalPersonVO> query(Integer id);

    @Update("update factory set enabled=#{enabled},legalPlantDec=#{legalPlantDec} where legalPlantCode=#{legalPlantCode}")
    void update(LegalPlantVO plantVo1);

    @Select("select * from factory where legalPersonCode = #{legalPersonCode}")
    LegalPlantUpdateStatus queryCode(String legalPersonCode);

    @Update("update factory set enabled = #{enabled} where legalPlantCode = #{legalPlantCode}")
    void updateStatus(LegalPlantVO legalPlantVO1);
}
